<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>50bus-个人中心</title>
    <meta name="keywords" content="50bus" />
    <meta name="copyright" content="50bus.cn" />
    <!-- <meta http-equiv="mobile-agent" content="http://www.50bus.cn/" />
    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" /> -->
    <link rel="icon" href="/resources/img/favicon.ico" type="image/x-icon" />
    
    <link rel="stylesheet" type="text/css" href="/resources/css/base.css" media="all" />
    <link rel="stylesheet" type="text/css" href="/resources/css/globe.css" media="all" />
    <link rel="stylesheet" type="text/css" href="/resources/css/module-userhome.css" media="all" />
    <link rel="stylesheet" href="/resources/kindeditor/themes/default/default.css" />
    <script type="text/javascript" src="/resources/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/resources/js/jquery.validate.js"></script>
    <script type="text/javascript" src="/resources/js/jquery.form.js"></script>
</head>

<body>
    <div class="header_wrap">
        <div class="header clearfix">
            <div class="fm980 fl clearfix">
                <a href="/index.html" class="logo fl"></a>
                <ul class="nav_box fl">
                    <li><a href="/creative_list.html">形象创意</a></li>
                    <li><a href="/script_list.html">剧本创作</a></li>
                    <li><a href="/render_index.html">动画渲染</a></li>
                    <li><a href="/creative_helper.html">创意助手</a></li>
                </ul>
                <div class="about_box fr">
                    <a href="/about.html">关于我们</a>
                    <a href="/user/user_work.html" class="cur">${user.comp}个人空间</a>
                    <a href="/logout.html">退出</a>
                </div>
            </div>
        </div>

    </div>

    <div class="body_wrap">
        <div class="handle_bar">
            <div class="fm980"><p class="fz16 pt5"></p></div>
        </div>
        <div class="user_home_box fm980 clearfix">
            <div class="nav_left fl">
                <a class="icon_edit" href="/user/user_info.html"></a>
                <b class="corner"></b>
                <div class="user_info clearfix">
                    <#if user?? && user.header_img?? && user.header_img != ''>
                    	<span class="user_pic fl"><img src="${user.header_img}" /></span>
                    <#else>
                    	<span class="user_pic fl"><img src="/resources/img/user_def_70.png" /></span>
                    </#if>
                    <p>
                        <span class="user_name">${user.comp}</span>
                        <span style="display:none;" class="like_box_14"><b class="fav_heart"></b> 56422</span>
                    </p>
                </div>
                <div class="nav_list">
                    <ul>
                        <li><a href="/user/user_work.html" >我的作品</a></li>
                        <li><a href="/user/user_trade.html">我的交易</a></li>
                        <li><a href="/user/user_account.html">我的账户</a></li>
                        <li><a href="/user/user_info.html" class="cur">个人信息</a></li>
                    </ul>
                </div>
            </div>
            <!-- 我的账户 > 账户充值 -->
            <div class="home_con fl">
            	<div class="tab_box sep_line">
                    <a href="javascript:void(0);" class="cur" tab-index="1">资料修改</a>
                    <a href="javascript:void(0);" tab-index="2">密码修改</a>
                </div>
                <div class="account_info account_pay sep_line" ref="1">
                    <form id="infoForm" action="/user/editInfo.json" method="POST">
                    	<input name="uid" type="hidden" value="${user.uid}"/>
	                    <ul>
	                        <li class="clearfix">
	                            <span class="t">账号/邮箱：</span>
	                            <p>${user.email}</p>
	                        </li>
	                        <li class="clearfix">
	                            <span class="t">昵称/公司名：</span>
	                            <p><input class="input_txt" name="comp" type="text" required="true" maxlength="20" value="${user.comp}"/></p>
	                        </li>
	                        <li class="clearfix">
	                        	<input name="header_img" type="hidden" value="${user.header_img}"/>
	                            <span class="t">头像：</span>
	                            <#if user?? && user.header_img?? && user.header_img != ''>
			                    	<p><span class="user_pic fl"><img style="cursor:pointer;width:70px;height:80px;" src="${user.header_img}" /></span></p>
			                    <#else>
			                    	<p><span class="user_pic fl"><img style="cursor:pointer;width:70px;height:80px;" src="/resources/img/user_def_70.png" /></span></p>
			                    </#if>
	                            
	                        </li>
	                        <li class="mt30 clearfix">
	                            <p><a href="javascript:;" id="cashBtn" class="btn_com_purple">保存</a></p>
	                        </li>
	                    </ul>
                    </form>
                </div>
                <div class="account_info account_pay sep_line" ref="2" style="display:none;">
                    <form id="pwdForm" action="/user/editPsw.json" method="POST">
                    	<input name="uid" type="hidden" value="${user.uid}"/>
	                    <ul>
	                    	<li class="clearfix">
	                            <span class="t">旧密码：</span>
	                            <p><input class="input_txt" name="old_pwd" type="password" /></p>
	                        </li>
	                        <li class="clearfix">
	                            <span class="t">新密码：</span>
	                            <p><input class="input_txt" name="pwd1" type="password" /></p>
	                        </li>
	                         <li class="clearfix">
	                            <span class="t">再次输入：</span>
	                            <p><input class="input_txt" name="pwd2" type="password" /></p>
	                        </li>
	                        <li class="mt30 clearfix">
	                            <p><a href="javascript:;" id="cashBtn" class="btn_com_purple">保存</a></p>
	                        </li>
	                    </ul>
                    </form>
                </div>

            </div>
        </div>

    </div>

    <div class="footer">
        <div class="fm980 clearfix">
            <div class="foot_link foot_link1 fl">
                <a href="/creative_list.html">形象创意</a>
                <a href="/script_list.html">剧本创作</a>
                <a href="/render_index.html">动画渲染</a>
                <a href="/creative_helper.html" >创意助手</a>
            </div>
            <div class="foot_link foot_link2 fl">
                <a href="http://zjusp.zju.edu.cn/">浙大科技园</a>
                <a href="http://www.zju.edu.cn/">浙江大学</a>
                <a href="/about.html" >关于我们</a>
            </div>
            <div class="copy_box fr">
                <img class="mb5" src="/resources/img/foot_text.png" />
                <p>&copy; 2013-2016 All right reserved</p>
                <p><a href="">服务条款</a><a href="">隐私条款</a><a href="">法律条款</a></p>
                <p style="display:none;"><a href="" class="share_icon share_sina"></a><a href="" class="share_icon share_wx"></a></p>
            </div>
        </div>
    </div>
<script src="/resources/kindeditor/kindeditor.js"></script>
<script src="/resources/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
$(function(){
	
	//验证表单
	$("#infoForm").validate({
		messages: { 
			comp: { 
				required: "请输入昵称/公司名", 
				maxlength: "标题不能超过{0}字"
			}
		},
		errorElement: "em",
		errorPlacement: function (error, element) { 
	  		if (element.is(':radio') || element.is(':checkbox')) {
	      		var eid = element.attr('name');
	      		error.appendTo(element.parent());
	  		} else {
	      		error.appendTo(element.closest("p"));
	 		}
		},
		submitHandler:function(form){
	        formSubmit($("#infoForm"));
	    } 
	});
	
	$("#pwdForm").validate({
			rules: {
			old_pwd: { 
				required: true                       
			},
			pwd1: { 
				required: true,                           
				rangelength: [7,11] 
			}, 
			pwd2: { 
				required: true, 
				rangelength: [7,11],
				equalTo: 'input[name="pwd1"]' 
			}
		}, 
		messages: { 
			old_pwd: { 
				required: "请输入原始密码", 
			}, 
			pwd1: { 
				required: "请输入新密码", 
				rangelength: "请输入7到11个字符"
			}, 
			pwd2: { 
				required: "请再次输入新密码", 
				rangelength: "请输入7到11个字符", 
				equalTo: "两次输入密码不一致" 
			}
		},
		errorElement: "em",
		errorPlacement: function (error, element) { 
	  		if (element.is(':radio') || element.is(':checkbox')) {
	      		var eid = element.attr('name');
	      		error.appendTo(element.parent());
	  		} else {
	      		error.appendTo(element.closest("p"));
	 		}
		},
		submitHandler:function(form){  
	        formSubmit($("#pwdForm"));
	    } 
	});
	


	$('.tab_box a').click(function(){
		var index = $(this).attr("tab-index");
		var conts = $('.account_info');
		for(var i=0;i<conts.length;i++){
			if(conts.eq(i).attr("ref") == index){
				conts.eq(i).show();
			}else{
				conts.eq(i).hide();
			}
		}
		$(this).siblings("a").removeClass("cur");
		$(this).addClass("cur");
	});
	
	var editor = KindEditor.editor({
		allowFileManager : true
	});
	
	$('.account_info .user_pic img').click(function(){
		var img = $(this);
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				showRemote : false,
				imageUrl : $('input[name="header_img"]').val(),
				clickFn : function(url, title, width, height, border, align) {
					$(img).attr('src',url);
					$('input[name="header_img"]').val(url);
					editor.hideDialog();
				}
			});
		});
	});
	
	$('.btn_com_purple').click(function(){
		var form = $(this).parents('form').first();
		$(form).submit();
	});
})

function formSubmit(form){
    form.ajaxSubmit({
        dataType: "json",                
		success: function(json)     
        {
        	if(json.statusCode==200)         
        	{
        		alert("修改成功");
        		location.href= location.href;
        	}
        	else
        	{                                 
        		alert(json.message);
        	}
        }
    });
};
</script>
<script type="text/javascript" src="/resources/js/page-index.js"></script>
<script type="text/javascript">
	<#if uid??&&uid!="">
    	$.post("/common/getUserName.json",{"uid":${uid}},function(data){
    		if(data.name){
    			$('a[href="/user/user_work.html"]').html(data.name+"个人空间");
    		}
    	});
	 </#if>
</script>
</body>

</html>